<?php
/**
 * Created by xiaosong
 * E-mail:4155433@gmail.com
 * Date: 2019/8/13
 * Time: 19:07
 */

namespace app\common\behavior;


use think\Db;
use think\response\Json;

class ApiEnd
{

    public function run(&$params)
    {

        if (request()->module() != 'api'){
            return false;
        }

        global $EXTEND;



        if (!empty($EXTEND) && $params instanceof Json && is_int($EXTEND['user_id'])){
            $result = Db::name('user_extend')->where('user_id',$EXTEND['user_id'])->update($EXTEND);
            if ($result === false){
                //如果更新失败就重复更新一次
                $result =  Db::name('user_extend')->where('user_id',$EXTEND['user_id'])->update($EXTEND);
            }
            return $result;
        }
        return false;


    }
}